package com.prs.crm.action.document;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.document.ThemeType;
import com.prs.crm.service.document.ThemeTypeService;

public class ThemeTypeAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private ThemeType themeType;
	private ThemeTypeService themeTypeService;
	private PaginationSupport pagination;
	private Integer[] ids;
	public ThemeType getThemeType() {
		return themeType;
	}
	public void setThemeType(ThemeType themeType) {
		this.themeType = themeType;
	}
	public ThemeTypeService getThemeTypeService() {
		return themeTypeService;
	}
	public void setThemeTypeService(ThemeTypeService themeTypeService) {
		this.themeTypeService = themeTypeService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	
	@Action("listThemeType")
	public String listThemeType(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(ThemeType.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getThemeTypeService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("editThemeType")
	public String editThemeType(){
		return SUCCESS;
	}
	
	@Action(value="saveThemeType",results={
			@Result(name="success",type="redirect",location="listThemeType"),
			@Result(name="error",type="chain",location="editThemeType")
	})
	public String saveThemeType(){
		this.getThemeTypeService().save(themeType);
		return SUCCESS;
	}
	
	@Action(value="removeThemeType",results={
			@Result(name="success",type="redirect",location="listThemeType"),
			@Result(name="error",type="chain",location="listThemeType")
	})
	public String removeThemeType(){
		if (ids==null) {
			this.setPrompt("请选择一行！");
			return ERROR;
		}
		this.getThemeTypeService().batchRemove(ids);
		return SUCCESS;
	}
}
